from django.conf import settings
from django.shortcuts import render_to_response
from django.template import RequestContext
from django.contrib.auth.forms import AuthenticationForm
from django.http import HttpResponseRedirect as redirect
from django.contrib.auth import authenticate
from StartGroup.models import Group
from groupAlbum.forms import AlbumUploadForm
import StartGroup.Constants
import Constants
import connectpeople.Constants
from  django.http import QueryDict

# render form for Group Album Upload
def groupAlbumFormView(request, group_web_address):
 
    group = Group.objects.get(group_web_address=group_web_address)
    
    return render_to_response("groupAlbum/groupAlbumForm.html",
                          {'album_form': AlbumUploadForm(), 'group':group},
                          context_instance = RequestContext(request))
    

# Save the form
def albumSave(request, group_web_address):
    
    group_web_addr = group_web_address
        
    if request.method == 'POST':
        # Save and insert new row in table
        group_album_form = AlbumUploadForm(data=request.POST, files=request.FILES)
        print request.FILES
        if group_album_form.is_valid():
            group_album_form.save(group_web_addr)
                 
    return redirect('/connectpeople/photologue/photogallery')

